package com.lik.javadeep.basic.search;

public class BinarySearch {
    // 黄金分割 1364/2207
    public static void main(String[] args) {
        int[] ints = {1, 2, 5, 6, 9, 10, 18};
        int target = 9;
        int result = search(ints, 0, ints.length, 2);

        System.out.println(result);

        // Arrays.con()

    }

    private static int search(int[] array, int lo, int high, int target) {
        while (lo != high) {
            int middle = (lo + high) >> 1;
            if (array[middle] == target) {
                return middle;
            } else if (target < array[middle]) {
                high = middle;
            } else {
                lo = middle + 1;
            }
        }

        return -1;
    }


}
